IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = object_id(N'[dbo].[or_UserProfileUpdate]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
DROP PROCEDURE dbo.[or_UserProfileUpdate]
Go

CREATE  PROCEDURE  dbo.[or_UserProfileUpdate]  
	@UserProfileID  int,
	@MeMaUserID  nvarchar(100), 
	@MentorStatusTypeID  int,
	@MentorRating  int,
	@LinkedInLink  nvarchar(1000),
	@FacebookLink  nvarchar(1000),
	@TwitterHandle  nvarchar(1000),
	@PersonalWebsite  nvarchar(1000),
	@Summary  nvarchar(max) 

AS  
  
  declare @DateTime datetime,@TranCountAtEntry int
  select @DateTime = getdate() 
BEGIN TRY 

IF @TranCountAtEntry  = 0 
BEGIN TRANSACTION 
UPDATE UserProfile SET 
UserProfileID = @UserProfileID, 
MeMaUserID = @MeMaUserID, 
Picture = null, 
MentorStatusTypeID = @MentorStatusTypeID, 
MentorRating = @MentorRating, 
LinkedInLink = @LinkedInLink, 
FacebookLink = @FacebookLink, 
TwitterHandle = @TwitterHandle, 
PersonalWebsite = @PersonalWebsite, 
Summary = @Summary, 
LastModDate = GETDATE()
WHERE UserProfileID = @UserProfileID
 
IF @@TRANCOUNT > @TranCountAtEntry
COMMIT TRANSACTION

END TRY
BEGIN CATCH
  
  IF @@TRANCOUNT > @TranCountAtEntry
  ROLLBACK TRANSACTION

  -- Raise an error with the details of the exception
  or_raiseerror 

END CATCH
  
  